package Person.controller;

import Person.Base.BaseRangeException;
import Person.models.BaseClass;
import Person.views.NewObjet;

import java.util.Scanner;

public class PerSonController {
    public static BaseClass create(){
        Scanner newScanner = new Scanner(System.in);
        do {
            System.out.println("请输入类型 （0 猫 1 狗）");
            try {
               return NewObjet.CreateObject(newScanner.nextInt());
            } catch (BaseRangeException e) {
                System.out.println("输入有误，请重新输入");
            }
        }while (true);
    }

    public static void setObjectSex(BaseClass newObjects){
        Scanner newScanner = new Scanner(System.in);
        do {
            System.out.println("请输入类型 （0 雌 其他 雄）");
            try {
                newObjects.setSex(newScanner.nextInt());
                break;
            } catch (BaseRangeException e) {
                System.out.println("输入有误，请重新输入");
            }
        }while (true);
    }

    public static void setObjectHealthy(BaseClass newObjects){
        Scanner newScanner = new Scanner(System.in);
        do {
            System.out.println("请输入亲和度");
            try {
                newObjects.setHealthy(newScanner.nextInt());
                break;
            } catch (BaseRangeException e) {
                System.out.println("输入有误，请重新输入");
            }
        }while (true);
    }

    public static void setObjectIntimacy(BaseClass newObjects){
        Scanner newScanner = new Scanner(System.in);
        do {
            System.out.println("请输入健康值");
            try {
                newObjects.setIntimacy(newScanner.nextInt());
                break;
            } catch (BaseRangeException e) {
                System.out.println("输入有误，请重新输入");
            }
        }while (true);
    }

    public static void setObjectName(BaseClass newObjects){
        System.out.println("请输入名称");
        Scanner newScanner = new Scanner(System.in);
        newObjects.setName(newScanner.next());
    }
}
